﻿//++
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// Module Name:
//
//  AddEditChannelDialogTest.cs
//    
// Abstract:
//
//  Unit tests for the AddEditChannelDialog
//  
//--

using Microsoft.EnhancedReminders.OutlookAddIn;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.EnhancedReminders;

namespace Microsoft.EnhancedReminders.OutlookAddIn.UnitTests
{
       
    /// <summary>
    ///This is a test class for AddEditChannelDialogTest and is intended
    ///to contain all AddEditChannelDialogTest Unit Tests
    ///</summary>
    [TestClass()]
    public class AddEditChannelDialogTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        /// Confirm that a brand new channel should be invalid (since name and value are null)
        ///</summary>
        [TestMethod()]
        public void TestNewChannelIsInvalid()
        {
            AddEditChannelDialog target = new AddEditChannelDialog(null); // TODO: Initialize to an appropriate value
            
            Assert.IsFalse(target.IsChannelValid);
        }

        /// <summary>
        /// Confirm a channel with no name but a valid value is invalid
        /// </summary>
        [TestMethod()]
        public void TestNoNameValidValue()
        {
            AddEditChannelDialog target = new AddEditChannelDialog(new NotificationChannel(NotificationChannelType.Communicator, "", "john@contoso.com"));

            Assert.IsFalse(target.IsChannelValid);
        }

        /// <summary>
        /// Confirm a channel with a name but no value is invalid
        /// </summary>
        [TestMethod()]
        public void TestNameNoValue()
        {
            AddEditChannelDialog target = new AddEditChannelDialog(new NotificationChannel(NotificationChannelType.Communicator, "Communicator", ""));

            Assert.IsFalse(target.IsChannelValid);
        }

        /// <summary>
        /// Confirm a valid communicator channel
        /// </summary>
        [TestMethod()]
        public void TestValidChannel()
        {
            AddEditChannelDialog target = new AddEditChannelDialog(new NotificationChannel(NotificationChannelType.Communicator, "Communicator", "john@contoso.com"));

            Assert.IsTrue(target.IsChannelValid);
        }

        /// <summary>
        /// Confirm a full sip address is invalid (i.e. sip:john@contoso.com should be invalid because it has "sip:")
        /// </summary>
        [TestMethod()]
        public void TestSipAddress()
        {
            AddEditChannelDialog target = new AddEditChannelDialog(new NotificationChannel(NotificationChannelType.Communicator, "Communicator", "sip:john@contoso.com"));

            Assert.IsFalse(target.IsChannelValid);
        }

        /// <summary>
        /// Confirm a valid phone channel; make sure we allow the correct values
        /// </summary>
        [TestMethod()]
        public void TestValidPhoneChannel()
        {
            AddEditChannelDialog target = new AddEditChannelDialog(new NotificationChannel(NotificationChannelType.Phone, "Mobile", "1234567890()+- "));

            Assert.IsTrue(target.IsChannelValid);
        }
    }
}
